/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package model.dao;

import javax.persistence.Query;
import model.Turma;

/**
 *
 * @author Patrick
 */
public class TurmaDAO extends BaseDAO<Turma>{
    public Turma pesquisaPorHorario(String horario){
        Turma turma;
        Query query = getEntityManager().createQuery(
                "SELECT turma FROM  " + Turma.class.getName() + " turma WHERE turma.horario LIKE :horario");
        query.setParameter("horario", "%"+horario+"%"); 
        if (query.getResultList().isEmpty()) {
            turma = null;
        } else {
            turma = (Turma) query.getSingleResult();
        }
        return turma;
    }
}
